﻿using AnQinFrameWorkAPI.Entity.Blog.DTO.BlogProjectCase;
using AnQinFrameWorkAPI.Entity.Blog.View.BlogProjectCase;
using AnQinFrameWorkAPI.Service.Blog;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Blog;

/// <summary>
///     项目案例API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Blog")]
public class BlogProjectCaseController : ControllerBase
{
    // 业务服务接口
    private readonly BlogProjectCaseService _blogProjectCaseService;

    // 构造注入
    public BlogProjectCaseController(BlogProjectCaseService blogProjectCaseService)
    {
        _blogProjectCaseService = blogProjectCaseService;
    }

    /// <summary>
    ///     获取项目案例列表（分页）
    /// </summary>
    /// <param name="searchDTO">查询条件</param>
    [ProducesResponseType(typeof(BlogProjectCaseView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetBlogProjectCaseList([FromQuery] BlogProjectCaseSearchDTO searchDTO)
    {
        var response = await _blogProjectCaseService.GetBlogProjectCaseList(searchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增项目案例
    /// </summary>
    /// <param name="addDTO">案例数据</param>
    [HttpPost]
    public async Task<IActionResult> AddBlogProjectCase([FromBody] BlogProjectCaseAddDTO addDTO)
    {
        var response = await _blogProjectCaseService.AddBlogProjectCase(addDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新项目案例
    /// </summary>
    /// <param name="updateDTO">案例数据</param>
    [HttpPut]
    public async Task<IActionResult> PutBlogProjectCase([FromBody] BlogProjectCaseUpdateDTO updateDTO)
    {
        var response = await _blogProjectCaseService.PutBlogProjectCase(updateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除项目案例
    /// </summary>
    /// <param name="deleteDTO">删除参数</param>
    [HttpDelete]
    public async Task<IActionResult> DeleteBlogProjectCase([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _blogProjectCaseService.DeleteBlogProjectCase(deleteDTO);
        return StatusCode(response.Status, response);
    }
}